<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <title><?php echo $this->page_title;?></title>
    <link rel="stylesheet" type="text/css" href="/style/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/style/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/style/css/xshop.css?ver=20170916" />
    <script src="/style/js/jquery-1.12.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/style/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/style/js/xShop.js" type="text/javascript" charset="utf-8"></script>
    </head>
<body>
<div class="outwrap">
	<!--top-->	
	<!-- <div class="topbar clearfix topvh">
		<a href="/user_extract/my_bank" class="btn-back">
			<i class="ico-back"></i><span>编辑银行卡</span>
		</a>
	</div> -->
  <div class="meinner-adr-add">
    <div class="tixian-jilu">
    <form method="post" id="updateForm">
      <ul class="tixadd">
        <li><span>开&nbsp;&nbsp;户&nbsp;&nbsp;行：</span>
            <select  name="bank_id" id="bank_id">
              <option value="">请选择银行</option>
              <?php foreach($this->c['bank'] as $k=>$v):?>
                  <option <?php if($this->info['bank_id']==$k):?> selected="selected" <?php endif;?>value="<?=$k?>"><?=$v?></option>
             <?php endforeach;?>
            </select>
        </li>
        <input name="id" type="hidden" value="<?=$this->info['id'];?>"/>
        <li><span>支行名称：</span><p><input name="branch" id="branch" type="text" value="<?=$this->info['branch'];?>" class="txt" placeholder="请输入支行名称" /></p></li>
        <li><span>卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span><p><input name="card_number" id="card_number" value="<?=$this->info['card_number'];?>" type="text" class="txt" placeholder="请输入银行卡号" /></p></li>
        <li><span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</span><p><input name="account_name" id="account_name"value="<?=$this->info['account_name'];?>" type="text" class="txt" placeholder="请输入您的姓名" /></p></li>
        <li><span>身&nbsp;&nbsp;份&nbsp;&nbsp;证：</span><p><input name="card_no" id="card_no" value="<?=$this->info['card_no'];?>" type="text" class="txt" placeholder="请输入身份证号" /></p></li>
      </ul>
      </form>
    </div>
    <div class="btnwrap">
      <input type="button" class="btn-mexl btn-bc btn-mng" style="width: 40%;" id="edit_btn" value="保存" />
      <input type="button" class="btn-mexl btn-bc btn-mng" style="width: 40%;float: right;margin-top: -45px" onClick="del_btn(<?=$this->info['id']?>)" value="删除" />
    </div>
  </div>

</div>
<script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
<link type="text/css" rel="stylesheet" href="/style/css/sweet-alert.css">
<script type="text/javascript">
$(function(){
  //分类选择
  $('.sortslt select').change(function(){
    var thisTxt = $(this).find('option:selected').text();
    $(this).prev('span').text(thisTxt);
  });

  $("#edit_btn").click(function(){
    if($("#bank_id").val()==""){
      swal("请选择银行");
      return false;
    }
     if($("#card_number").val()==""){
      swal("请输入卡号");
      return false;
    }else{
      if(!$.isNumeric($("#card_number").val())){
        swal("卡号必须全部为数字");
         return false;
      }
    }

     if($("#account_name").val()==""){
      swal("请输入帐户姓名");
      return false;
    }
     if($("#card_no").val()==""){
      swal("请输入身份证号");
      return false;
    }else{
      cardp=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
      if(!cardp.test($("#card_no").prop("value"))){
       swal("身份证号格式不正确");
       return false;

       }
    }

      $("#edit_btn").hide();
    $.ajax({type:"POST",url:"ajax",dataType:"json",data:$("#updateForm").serialize()+"&act=edit_bank",async: false, success:function(data){
         $("#edit_btn").show();
            if(data.code==200){
                swal("编辑","编辑银行卡成功","success");
                setTimeout(function(){
                	location.href="/wallet/my_bank";
                },2100);
            }else{
                swal("编辑","编辑银行卡失败","error");
            }
      }
    });


  });
})

    //银行卡删除
    function del_btn(id) {
        $.ajax({type:"POST",url:"del_bank",dataType:"json",data:{id:id,},async: false,
            success:function(data){
                $("#del_btn").show();
                if(data.code==200){
                    swal("删除成功");
                    setTimeout(function(){
                    	location.href="/wallet/my_bank";
                    },2100);
                }else{
                    swal("操作失败，请重新操作");
                }
            }
        });
    }


</script>

<!--底部导航-->
	<div class="foot-menu">
    <ul class="clearfix">
      <li><a href="/index/index"><i class="ico-1"></i><span>首页</span></a></li>
        
        <li><a href="/cart/cart"><i class="ico-5"></i><span>购物车</span></a></li>
        <li><a href="#"><i class="ico-3"></i><span>客服</span></a></li>
        <li class="on"><a href="/user/index"><i class="ico-4"></i><span>我的</span></a></li>
    </ul>
  </div>
</body>
</html>
